package com.dy.dept.controller;


import com.dy.dept.dto.DeptDto;
import com.dy.dept.entity.Dept;
import com.dy.dept.service.IDeptService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dy
 * @since 2022-03-22
 */
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private IDeptService deptService;

    @GetMapping("/select/{role}/{id}") //http://127.0.0.1:8080/dept/select/role/1
    public List<DeptDto> getDeptAndDeptInfoById(@PathVariable("id") Integer id){
        System.out.println(id);
        return deptService.getDeptAndDeptInfoById(id);
    };
    @GetMapping("/selectAll/{role}")
    public List<DeptDto> getAllDeptAndDeptInfo(){
        return deptService.getAllDeptAndDeptInfo();
    }
}
